<template>
  <div v-if="!store.isLogin">
    <UserLayoutView/>
  </div>
  <div v-else>
    <div class="App">
      <div class="header">
        <GlobalHeader />
      </div>
      <div class="aside">
        <GlobalAside />
      </div>
      <div class="content" style="padding-left: 220px; padding-top: 80px; padding-right: 20px">
        <RouterView />
        <div class="footer"></div>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import { useRouter } from 'vue-router'
import { useUserStore } from '@/stores/user.ts'
import { ElMessage } from 'element-plus'
import GlobalHeader from '@/components/GlobalHeader.vue'
import GlobalAside from '@/components/GlobalAside.vue'
import UserLayoutView from '@/views/user/UserLayoutView.vue'
const router = useRouter()
const store = useUserStore()
router.beforeEach((to, from, next) => {
  if (to.meta?.isAuth) {
    if (store.isLogin) {
      next()
    } else {
      ElMessage.error('未登录！您无法查看此页面')
    }
  } else {
    next()
  }
})
</script>
<style scoped></style>
